package likou;

/**
 * @author: Tangxz
 * @email: 1171702529@qq.com
 * @cate: 2021/02/05 13:10
 */
public class _1208 {
    public static void main(String[] args) {
        System.out.println(equalSubstring("nfyvfrvrbinpwkepscnnzfyiuznrp",
                "eclliczkrezvhyvoyhbuurhkhtvto",
                194));
    }
    public static int equalSubstring(String s, String t, int maxCost) {
        int left = 0,right=0;
        int len = s.length();
        int nowCost = 0;
        byte[] sb = s.getBytes();
        byte[] tb = t.getBytes();
        while(right<len){
            nowCost+=Math.abs(sb[right]-tb[right]);
            if(nowCost>maxCost){
                nowCost-=Math.abs(sb[left]-tb[left]);
                left++;
            }
            right++;
        }
        return right-left;
    }
}
